package com.vecspace.utils.log;

/**URL 访问日志
 * 
 * @version: 1.0
 * @author: wanghua
 */
public class HttpRequestLog {
	private String loginId;
	private long reqStartTime;
	private long reqEndTime;
	private String funCode;
	private String funName;
	private int sqlCount = 0;
	private int totalSqlMills = 0;
	private int totalSqlRows = 0;
	
	/**URL访问开始
	 * 
	 *  
	 * @author: wanghua
	 */
	public void requestStart() {
		reqStartTime = System.currentTimeMillis();
	}
	/**URL访问结束
	 * 
	 *  
	 * @author: wanghua
	 */
	public void requestEnd() {
		reqEndTime = System.currentTimeMillis();
	}
	
	/**设置URL请求的开始，结束时间
	 * 
	 * @param reqStartTime
	 * @param reqEndTime 
	 * @author: wanghua
	 */
	public void setRequestTime(long reqStartTime, long reqEndTime) {
		this.reqStartTime = reqStartTime;
		this.reqEndTime = reqEndTime;
	}
	
	/**增加一次SQL执行记录
	 * 
	 * @param sqlMills
	 * @param sqlRows 
	 * @author: wanghua
	 */
	public void addSql(int sqlMills, int sqlRows) {
		totalSqlMills += sqlMills;
		totalSqlRows += sqlRows;
		++sqlCount;
	}
	
	public void setFun(String funCode, String funName) {
		this.funCode = funCode;
		this.funName = funName;
	}
	
	public String getLoginId() {
		return loginId;
	}
	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}
	/**获取URL请求的耗时（ms）
	 * 
	 * @return 
	 * @author: wanghua
	 * @reviewer: 
	 */
	public int getReqMills() {
		return (int)(reqEndTime - reqStartTime);
	}

	public String getFunCode() {
		return funCode;
	}

	public void setFunCode(String funCode) {
		this.funCode = funCode;
	}

	public String getFunName() {
		return funName;
	}

	public void setFunName(String funName) {
		this.funName = funName;
	}

	public int getSqlCount() {
		return sqlCount;
	}

	public void setSqlCount(int sqlCount) {
		this.sqlCount = sqlCount;
	}

	public int getTotalSqlMills() {
		return totalSqlMills;
	}

	public void setTotalSqlMills(int totalSqlMills) {
		this.totalSqlMills = totalSqlMills;
	}

	public int getTotalSqlRows() {
		return totalSqlRows;
	}

	public void setTotalSqlRows(int totalSqlRows) {
		this.totalSqlRows = totalSqlRows;
	}
	
	
}
